package com.ssy.lingxi.open.api.controller;

import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.open.api.model.request.UserRequest;
import com.ssy.lingxi.open.api.model.response.UserResponse;
import com.ssy.lingxi.open.api.service.IUserService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * 用户管理类
 * @author jw.chen
 * @version 2.0.0
 * @date 2021/10/12
 */
@RestController
@RequestMapping("/openApi/user")
public class UserController {

    @Resource
    private IUserService userService;

    /**
     * 用户登录
     * @param userRequest 用户对象
     */
    @RequestMapping(value = "/login", method = RequestMethod.POST)
    public Wrapper<UserResponse> login(@RequestBody @Valid UserRequest userRequest) {
        return Wrapper.success(userService.login(userRequest.getAccount(), userRequest.getPassword()));
    }

}
